<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="ctx" th:content="${#httpServletRequest.getContextPath()}"/>
    <title>一号轴承网 </title>
    <link rel="shortcut icon" href="/img/logo.ico" type="image/x-icon">
    <meta name="keywords" content="一号轴承网">
    <meta name="description" content="一号轴承网">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/login.css" rel="stylesheet">
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-7">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>一号轴承网</h1>
                </div>
                <div class="m-b"></div>
                <h3>
                    欢迎使用 <strong>一号轴承网</strong>
                </h3>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        更精准
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 更便捷</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 更高效、更懂你</li>
                </ul>

            </div>
        </div>
        <div class="col-sm-5">
            <form id="signupForm">
                <h3 class="text-center">用户登录</h3>
                <p class="m-t-md text-center">欢迎登录一号轴承网会员中心</p>
                <input type="text" name="username" class="form-control uname"
                       value=""/>
                <input type="password" name="password"
                       class="form-control pword m-b" value=""/>
                <button class="btn btn-login btn-block" id="denglu">登录</button>
                <!--按钮模块-->
                <div class="outside-login">
                    <div class="outside-login-tit">
                        <span>登陆角色</span>
                    </div>
                    <div class="outside-login-cot">
                        <label class="radio-inline">
                            <input type="radio" name="roleType" checked="checked" value="1"/> 会员
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="roleType" value="2"/> 管理员
                        </label>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">&copy; 2018 All Rights Reserved. 一号轴承网
        </div>
    </div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]] ; </script>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="/js/bootstrap.min.js?v=3.3.6" th:src="@{/js/bootstrap.min.js?v=3.3.6}"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0" th:src="@{/js/content.js?v=1.0.0}"></script>

<!-- jQuery Validation plugin javascript-->
<script src="/js/plugins/validate/jquery.validate.min.js" th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="/js/plugins/validate/messages_zh.min.js" th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">
    $(document).ready(function () {

        console.log(ctx);
        validateRule();

    });

    $.validator.setDefaults({
        submitHandler: function () {
            login();
        }
    });

    function login() {
        $.ajax({
            type: "POST",
            url: ctx+"login",
            data: $('#signupForm').serialize(),
            success: function (r) {
                if (r.code == 0) {
                    if (r.data=="member"){
                        parent.location.href = '/front/index';
                    }else if (r.data=="admin") {
                        parent.location.href = '/member/welcome';
                    }
                } else {
                    layer.msg(r.msg);
                }
            }
        });
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                username: {
                    required: true
                },
                password: {
                    required: true
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名",
                },
                password: {
                    required: icon + "请输入您的密码",
                }
            }
        })
    }



    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            $("#denglu").click();
        }
    });

</script>

</body>


</html>
